{{ include("common/header.html")}}
<div class="admin">
    {{ include("common/nav.html")}}
    <div class="aright">
        <div class="arz" style="float: left;margin: 0px 20px 20px 30px;"><a href="{{ G.url('admin/advertisement/add')}}"><i class="layui-icon">&#xe608;</i>添加广告</a></div>

       <!-- <div style="float: left;">
            <form class="layui-form" action="/admin.php/article/index.html" method="get">
                <input placeholder="输入关键字" name="kw" value="" type="text" class="layui-input" style="float: left;margin-right: 10px;width: 300px;">
                <button class="layui-btn" style="float: left;" value="查询" type="submit">查询</button>
            </form>
        </div>-->

        <form method="post" class="aform cl">
            <table width="100%">
                <tbody><tr>
                    <th width="5%" align="center">排序</th>

                    <th width="15%" align="center">广告名称</th>
                    <th width="10%" align="center">广告位置</th>
                    <th width="18%" align="center">广告图片</th>
                    <th width="30%" align="center">跳转地址</th>
                    <th width="10%" align="center">广告类别</th>
                    <th width="12%" align="center">基本操作</th>
                </tr>
                {% for data in list %}

                 <tr>
                    <td align="center">{{loop.index}}</td>
                    <td align="center" style="
                            width:150px;display: block;
                            overflow: hidden;
                            text-overflow: ellipsis;
                            line-height: 50px;
                            max-height: 50px;
                            -webkit-line-clamp: 1;
                            cursor:pointer;
                            -webkit-box-orient: vertical;">{{ data.name }}</td>
                    <td align="center">

                        {% if data.cid==1 %}
                        首页
                        {% elseif data.cid==2 %}
                        分类页
                        {% elseif data.cid==3 %}
                        帖子详情页


                        {% else %}
                        友情链接
                        {% endif %}

                    </td>
                    <td align="center">
                        <img src="{{_G['ATTACHMENT_ROOT']}}/{{ data.image }}" height="30">
                    </td>
                     <td align="center"  >
                         <a target="_blank" href="{{ data.url_path }}"
                            style="
                            width:300px;display: block;
                            overflow: hidden;
                            text-overflow: ellipsis;
                            display: -webkit-box;
                            line-height: 50px;
                            max-height: 50px;
                            -webkit-line-clamp: 1;
                            cursor:pointer;
                            -webkit-box-orient: vertical;">
                             {{ data.url_path }}</a></td>
                    <td align="center">{% if data.type==1 %}文字{% else %}图片{% endif %}</td>
                    <td align="center" >
                        <a href="{{ G.url('admin/advertisement/edit',{id:data.id})}}"><i class="layui-icon" style="font-size: 20px; color: #009688;">&#xe642;</i> 修改</a>
                        <a href="javascript:void(0)" onclick="del('{{ data.id }}');"><i class="layui-icon" style="font-size: 20px; color: #009688;">&#xe640;</i> 删除</a>
                    </td>
                </tr>
                {% endfor %}
               </tbody></table>
        </form>
        <div class="pages">

           <div id="pages"></div>
        </div>
    </div>
</div>

<script>
var testid=1;
var url="{{ G.url('app/index/index',{'id':'testid'})}}";
url = url.replace("testid", testid);//使用js自带函数进行变量替换

    /**
     * 构造分页功能
     */
    layui.use('laypage', function(){
        var laypage = layui.laypage;

        //完整功能
        laypage.render({
            elem: 'pages'
            ,count: "{{pagination.total}}", //数据总数，从服务端得到
            limit:"{{pagination.page_size}}",
            curr:"{{pagination.current_page}}",
            layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
            ,jump: function(obj,first){
                var url="{{ G.url('admin/advertisement/advertisementList',{'current_page':'currs','page_size':'limit'})}}";
                /**
                 * 替换处理
                  * @type {string}
                 */
                url = url.replace("currs", obj.curr);
                url = url.replace("limit", obj.limit);

                //首次不执行
                if(!first){

                    window.location.href=escapeUrl(url);//转义amp字符


                }

            }
        });

    });

</script>

<script>
    function del(id){
        layui.use('layer', function(){
            var layer = layui.layer;

            //信息框-例2
            layer.msg('您确定要删除吗？', {
                time: 0 //不自动关闭
                ,btn: ['确定', '取消']
                ,yes: function(index){
                    var url="{{ G.url('admin/advertisement/delete',{'id':'advertisementid'})}}";
                    url = url.replace("advertisementid", id);
                    window.location.href=escapeUrl(url);//转义amp字符
                }
            });
        });


    }
</script>
</body>
</html>